package cn.secby.system.api.factory;

import cn.secby.common.core.domain.R;
import cn.secby.distributor.api.RemoteDistributorService;
import cn.secby.distributor.api.model.DistributorLoginUser;
import cn.secby.system.api.domain.SysUser;
import cn.secby.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteDistributorFallbackFactory implements FallbackFactory<RemoteDistributorService>{

    @Override
    public RemoteDistributorService create(Throwable throwable) {
        return new RemoteDistributorService() {
            @Override
            public R<DistributorLoginUser> getUserInfo(String username, String source)
            {
                return R.fail("获取渠道商失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> registerUserInfo(SysUser sysUser, String source)
            {
                return R.fail("注册渠道商失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> recordUserLogin(SysUser sysUser, String source)
            {
                return R.fail("记录渠道商登录信息失败:" + throwable.getMessage());
            }
        };
    }
}
